﻿using MemberManager.Common.Utilities;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace MemberManager.Common.Classes
{
    /// <summary>
    /// 基础Helper类
    /// </summary>
    public class BaseHelper
    {
        /// <summary>
        /// 服务应用基础类库
        /// </summary>
        public hMailServer.Application _application;

        public BaseHelper()
        {
            if (Global.MailApplication == null)
            {
                //登录邮件服务器
                _application = APICreator.Create(Global.host);

                hMailServer.Account account = _application.Authenticate(Global.hmname, Global.hmpwd);
            }
        }

        /// <summary>
        /// 验证是否可以连接
        /// </summary>
        /// <returns></returns>
        public bool Verification()
        {
            if (Global.MailApplication == null)
            {
                //登录邮件服务器
                _application = APICreator.Create(Global.host);
                if (_application == null)
                    return false;
                hMailServer.Account account = _application.Authenticate(Global.hmname, Global.hmpwd);
                if (account == null)
                    return false;
                return true;
            }
            else
                return true;
        }
    }
}
